package com.yunjing.elasticjob.job;

import com.cxytiandi.elasticjob.annotation.ElasticJobConf;
import com.dangdang.ddframe.job.api.ShardingContext;
import com.dangdang.ddframe.job.api.simple.SimpleJob;
import lombok.extern.slf4j.Slf4j;

/**
 * @author zhiqi.shao
 * @Date 2018/6/12 17:37
 */
@Slf4j
@ElasticJobConf(name = "SimpleJob2", cron = "0/10 * * * * ?", eventTraceRdbDataSource = "datasource")
public class SimpleJob2 implements SimpleJob {

    /**
     * 执行分片任务
     *
     * @param context 分片信息上下文
     */
    @Override
    public void execute(ShardingContext context) {

        switch (context.getShardingItem()) {
            case 0:
                log.info("SimpleJob2 Sharding:" + 0);
                break;
            case 1:
                log.info("SimpleJob2 Sharding:" + 1);
                break;
            case 2:
                log.info("SimpleJob2 Sharding:" + 2);
                // do something by sharding item 2
                break;
            // case n: ...
            default:{log.info("SimpleJob2 not matching Sharding ");}
        }
    }




}
